package rock.common.constants;

public class RpcConstants {

    public static final int RPC_BUF_MAX_LEN = Integer.MAX_VALUE;

    // 连接zk超时秒数
    public static final int WAIT_TIMEOUT_CONNECT_ZK_SEC = 30;

    // 一致性hash算法额外虚拟节点数
    public static final int CONSISTENT_HASH_REPLICATE_NUM = 160;

    // port
    public static final int PORT         = 9998;

    // zk default address
    public static final String DEFAULT_ZOOKEEPER_ADDRESS = "127.0.0.1:2181";
    // zk register root path: docker docker exec -it id /bin/sh --> cd bin --> ./zkCli.sh --> ls / --> ls /my-rpc == [service.IUserService]
    public static final String ZK_REGISTER_ROOT_PATH = "/my-rpc";
    // zk retry sleep seconds
    public static final int ZK_SLEEP_SEC = 1000;
    // zk retry max cnt
    public static final int ZK_MAX_RETRIES = 3;


    public static final byte[] MAGIC_NUMBER = {(byte) 'r', (byte) 'r', (byte) 'p', (byte) 'c'};
    //version information
    public static final byte VERSION = 1;
    public static final byte TOTAL_LENGTH = 16;
    public static final byte REQUEST_TYPE = 1;
    public static final byte RESPONSE_TYPE = 2;
    //ping
    public static final byte HEARTBEAT_REQUEST_TYPE = 3;
    //pong
    public static final byte HEARTBEAT_RESPONSE_TYPE = 4;
    public static final int HEAD_LENGTH = 16;
    public static final String PING = "ping";
    public static final String PONG = "pong";
    public static final int MAX_FRAME_LENGTH = 8 * 1024 * 1024;

}
